import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import os
script_dir = os.path.dirname(os.path.abspath(__file__))
os.chdir(script_dir)
#加载数据
df = pd.read_csv('NotClean_EVUsage_Data.csv')
# 绘制能量消耗（kWh）的直方图
plt.figure(figsize=(10, 6))
sns.histplot(df['Energy (kWh)'], bins=20, kde=True)
plt.title('Energy Consumption Distribution')
plt.xlabel('Energy (kWh)')
plt.ylabel('Frequency')
plt.show()
# 绘制充电持续时间的箱型图
plt.figure(figsize=(10, 6))
sns.boxplot(x='Total Duration (hh:mm:ss)', data=df)
plt.title('Charging Duration Boxplot')
plt.show()
# 绘制GHG减排量的箱型图
plt.figure(figsize=(10, 6))
sns.boxplot(x='GHG Savings (kg)', data=df)
plt.title('GHG Savings Boxplot')
plt.show()
# 绘制充电费用的箱型图
plt.figure(figsize=(10, 6))
sns.boxplot(x='Fee', data=df)
plt.title('Charging Fee Boxplot')
plt.show()